﻿using System;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Threading;
using System.Windows.Forms;

namespace basic
{
    public partial class Form1 : Form
    {

        public string Kb = "KB articels: ";
        public String PKIAPP = "VPN / Entrust";
        public String PKICAUSE = "Password forgotten / expired";
        public string PKIISSUE = "Pki Password expired/ user forgot password";

        public String PkISTEPS = "User Validated. Recovered certificate following the standard " +
                                 "procedure. User could login,confirmed the " +
                                 "solution and was satisfied.";

        public string Usr521 = "5-2-1: ";
        public string UsrApp = "Application: ";
        public string UsrCause = "Cause: ";
        public string UsrCompMake = "Computer Make: ";
        public string UsrCompModel = "Computer Model:";
        public string UsrDate = "Date Of Issue: ";
        public string UsrEmail = "E-Mail: ";
        public string UsrHours = "Hours of Operation: ";
        public string UsrIssue = "Issue: ";
        public string UsrLob = "LOB: ";
        public string UsrLocation = "Cube/Office #: ";
        public string UsrName = "Full Name: ";
        public string UsrPhone = "Phone Number: ";
        public string UsrStation = "Workstation ID: ";
        public string UsrSteps = "TroubleShooting Step: ";

        public Form1()
        {
            InitializeComponent();
            
        }

        public static void Threadproc()
        {
            Application.Run(new startform()); 

        }
        public static void Threadprocabt()
        {
            Application.Run(new AboutBox());

        }
        /// <summary>
        ///     Create and populate notes.txt output
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button2_Click(object sender, EventArgs e)
        {
            string Fn = "note.txt";
            using (var fs = new FileStream(Fn, FileMode.Create))
            {
                using (var writer = new StreamWriter(fs))
                {
                    writer.WriteLine("Full Name: " + txtName.Text);
                    writer.WriteLine("");
                    writer.WriteLine("5-2-1: " + txt521.Text);
                    writer.WriteLine("");
                    writer.WriteLine("Phone Number: " + txtPhone.Text);
                    writer.WriteLine("");
                    writer.WriteLine("E-Mail: " + txtEmail.Text);
                    writer.WriteLine("");
                    writer.WriteLine("LOB: " + comboBox1.Text);
                    writer.WriteLine("");
                    writer.WriteLine("Application: " + txtApp.Text);
                    writer.WriteLine("");
                    writer.WriteLine("Issue: " + txtIssue.Text);
                    writer.WriteLine("");
                    writer.WriteLine("Cause: " + txtCause.Text);
                    writer.WriteLine("");
                    writer.WriteLine("TroubleShooting Step: " + txtActiontaken.Text);
                    writer.WriteLine("");
                    // writer.WriteLine("Date Of Issue: "+txtDate.Text);
                    writer.WriteLine("Date Of Issue: " + dateTimePicker1.Text);
                    writer.WriteLine("");
                    if (txtKB.Text == "")
                    {
                        writer.WriteLine("KB articels: N/A");
                    }
                    else
                    {
                        writer.WriteLine("KB articels: " + txtKB.Text);
                    }
                    writer.WriteLine("");
                    if (txtWrksta.Text == "")
                    {
                        writer.WriteLine("Workstation ID: N/A");
                    }
                    else
                    {
                        writer.WriteLine("Workstation ID: " + txtWrksta.Text);
                    }
                    writer.WriteLine("");
                    if (txtCube.Text == "")
                    {
                        writer.WriteLine("Cube/Office #: N/A");
                    }
                    else
                    {
                        writer.WriteLine("Cube/Office #: " + txtCube.Text);
                    }

                    writer.WriteLine("");
                    if (txtMake.Text == "")
                    {
                        writer.WriteLine("Computer Make: N/A");
                    }
                    else
                    {
                        writer.WriteLine("Computer Make: " + txtMake.Text);
                    }

                    writer.WriteLine("");
                    //if (txtModel.Text == "")
                    //{
                    //    writer.WriteLine("Computer Model: N/A");
                    //}
                    //else
                    //{
                    //    writer.WriteLine("Computer Model:" + txtModel.Text.ToString());
                    //}

                    writer.WriteLine("");
                    if (txtHours.Text == "")
                    {
                        writer.WriteLine("Hours of Operation: N/A");
                    }
                    else
                    {
                        writer.WriteLine("Hours of Operation: " + txtHours.Text);
                    }

                    writer.WriteLine("");
                    writer.WriteLine("Action: " + txtAction.Text);
                    writer.WriteLine("");
                    writer.WriteLine("Screenshot: " + cbScrnst.Text);
                    writer.Close();
                }
            }
            var Process = new Process();
            Process.StartInfo = new ProcessStartInfo
            {
                UseShellExecute = true,
                FileName = Fn
            };
            Process.Start();
            //Process.WaitForExit();
        }

        /// <summary>
        ///     Clear all fields to start over
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button1_Click(object sender, EventArgs e)
        {
            txtName.Clear();
            txt521.Clear();
            txtPhone.Clear();
            txtEmail.Clear();
            comboBox1.ResetText();
            txtMake.Clear();
            //txtModel.Clear();
            txtHours.Clear();
            txtApp.Clear();
            txtIssue.Clear();
            txtKB.Clear();
            txtCause.Clear();
            txtActiontaken.Clear();
            cbScrnst.ResetText();
            txtWrksta.Clear();
            txtCube.Clear();
            txtAction.Clear();
        }

        private void tableLayoutPanel1_Paint(object sender, PaintEventArgs e)
        {
        }

        /// <summary>
        ///     About loader
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Thread aboutthread = new Thread(new ThreadStart(Threadprocabt));
            aboutthread.Start();
            
        }

        private void saveToolStripMenuItem_Click(object sender, EventArgs e)
        {
        }

        private void saveFileDialog1_FileOk(object sender, CancelEventArgs e)
        {
        }

        /// <summary>
        ///     Update form based on template selection
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cbTemplates_SelectedIndexChanged(object sender, EventArgs e)
        {
            //if (cbTemplates.SelectedIndex == 3) ;
            //{
            //    //richTextBox1.Text = System.IO.File.ReadAllText(@"oki.txt");
            //}
            //if ((string) cbTemplates.SelectedItem == "DeskSide")
            //{
            //    //richTextBox1.Text = System.IO.File.ReadAllText(@"deskside.txt");
            //}
            //if ((string) cbTemplates.SelectedItem == "IOS")
            //{
            //}
            var poph = new pophelp(cbTemplates.SelectedIndex);


            /*
             * DeskSide
                IOS
                NaNet Password
                PKI Recovery
                Shared requests
             */


            switch (cbTemplates.SelectedIndex)
            {
                    //Desk Side
                case 1:
                    selection.Text = cbTemplates.SelectedIndex.ToString();
                    if (checkBox1.Checked)
                    {
                        poph.ShowDialog();
                    }
                    break;
                    //IOS
                case 2:
                    selection.Text = cbTemplates.SelectedIndex.ToString();
                    if (checkBox1.Checked)
                    {
                        poph.ShowDialog();
                    }

                    break;
                    //PKI
                case 3:
                    txtApp.Text = PKIAPP;
                    txtCause.Text = PKICAUSE;
                    txtIssue.Text = PKIISSUE;
                    txtActiontaken.Text = PkISTEPS;
                    selection.Text = cbTemplates.SelectedIndex.ToString();
                    if (checkBox1.Checked)
                    {
                        poph.ShowDialog();
                    }
                    break;
            }
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            //AboutBox ab = new AboutBox();
            Thread abthread = new Thread(new ThreadStart(Threadproc));
            abthread.Start();
        }

        private void splitContainer1_Panel2_Paint(object sender, PaintEventArgs e)
        {

        }
    }
}